package com.ruoyi.project.modules.filePageTagRef.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.modules.filePageTagRef.domain.FilePageTagRef;
import com.ruoyi.project.modules.filePageTagRef.service.IFilePageTagRefService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件与页面标签中间Controller
 * 
 * @author smallrain
 * @date 2022-03-22
 */
@Controller
@RequestMapping("/filePageTagRef/filePageTagRef")
public class FilePageTagRefController extends BaseController
{
    private String prefix = "filePageTagRef/filePageTagRef";

    @Autowired
    private IFilePageTagRefService filePageTagRefService;

    @RequiresPermissions("filePageTagRef:filePageTagRef:view")
    @GetMapping()
    public String filePageTagRef()
    {
        return prefix + "/filePageTagRef";
    }

    /**
     * 查询文件与页面标签中间列表
     */
    @RequiresPermissions("filePageTagRef:filePageTagRef:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FilePageTagRef filePageTagRef)
    {
        startPage();
        List<FilePageTagRef> list = filePageTagRefService.selectFilePageTagRefList(filePageTagRef);
        return getDataTable(list);
    }

    /**
     * 导出文件与页面标签中间列表
     */
    @RequiresPermissions("filePageTagRef:filePageTagRef:export")
    @Log(title = "文件与页面标签中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FilePageTagRef filePageTagRef)
    {
        List<FilePageTagRef> list = filePageTagRefService.selectFilePageTagRefList(filePageTagRef);
        ExcelUtil<FilePageTagRef> util = new ExcelUtil<FilePageTagRef>(FilePageTagRef.class);
        return util.exportExcel(list, "文件与页面标签中间数据");
    }

    /**
     * 新增文件与页面标签中间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存文件与页面标签中间
     */
    @RequiresPermissions("filePageTagRef:filePageTagRef:add")
    @Log(title = "文件与页面标签中间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FilePageTagRef filePageTagRef)
    {
        return toAjax(filePageTagRefService.insertFilePageTagRef(filePageTagRef));
    }

    /**
     * 修改文件与页面标签中间
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FilePageTagRef filePageTagRef = filePageTagRefService.selectFilePageTagRefById(id);
        mmap.put("filePageTagRef", filePageTagRef);
        return prefix + "/edit";
    }

    /**
     * 修改保存文件与页面标签中间
     */
    @RequiresPermissions("filePageTagRef:filePageTagRef:edit")
    @Log(title = "文件与页面标签中间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FilePageTagRef filePageTagRef)
    {
        return toAjax(filePageTagRefService.updateFilePageTagRef(filePageTagRef));
    }

    /**
     * 删除文件与页面标签中间
     */
    @RequiresPermissions("filePageTagRef:filePageTagRef:remove")
    @Log(title = "文件与页面标签中间", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(filePageTagRefService.deleteFilePageTagRefByIds(ids));
    }
}
